/**
 * All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
 * <p>
 * MpmProjectReviewService 项目复盘结项
 * <p>
 * 修改纪录 2021-01-18 版本：1.0 wudaliang 创建。
 *
 * @version 版本：1.0
 * @author 作者：wudaliang 创建日期：2021-01-18
 */
package com.topscomm.mpm.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.topscomm.basic.exception.ServiceException;
import com.topscomm.basic.util.SQLAdapter;
import com.topscomm.mpm.MpmSystemConst;
import com.topscomm.mpm.pojo.*;
import com.topscomm.mpm.service.*;
import com.topscomm.mpm.utils.ConvertTimeUtil;
import com.topscomm.pub.util.BaseUtil;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.Page;
import com.topscomm.pub.vo.Query;
import com.topscomm.pub.vo.ResponseResult;
import com.topscomm.tap.TapEntity;
import com.topscomm.tap.common.DatacodeCache;
import com.topscomm.tap.common.FlowDatacodeCache;
import com.topscomm.tap.common.SessionUserBean;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.mpm.service.impl.auto.MpmProjectReviewServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

@Service(value = "mpmProjectReviewService")
@Scope(value = "singleton")
public class MpmProjectReviewService extends MpmProjectReviewServiceAuto implements
    IMpmProjectReviewService {

    FlowDatacodeCache flowDatacodeCache = new FlowDatacodeCache();
    protected List<Map<String, Object>> flowidList = new ArrayList();

    @Autowired
    private MpmProjectService mpmProjectService;

    @Autowired
    private IMpmProjectMilepostService mpmProjectMilepostService;

    @Autowired
    private IMpmProjectWinBidInfoService mpmProjectWinBidInfoService;

    @Autowired
    private IMpmProjectTaskService mpmProjectTaskService;

    @Autowired
    private DatacodeCache datacodeCache;
    @Autowired
    private MpmProjectPerformanceJudgeService mpmProjectPerformanceJudgeService;

    @Autowired
    private IMpmProjectBidScoreService mpmProjectBidScoreService;
    @Autowired
    private MpmProjectChangeService mpmProjectChangeService;
    @Autowired
    private MpmProjectPolymerizationService mpmProjectPolymerizationService;

    /**
     * @author: wudaliang
     * @date: 2021-01-18
     * @param entity
     * @throws ServiceException
     * @description:单号生成
     * @modify:
     */
    @Override
    protected void beforeInsert(BasicEntity entity) {
        super.beforeInsert(entity);
        if (entity.getId() <= 0) {// 赋值Id和单号
            long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
            entity.setId(arrayId[0]);
            String docNo = String.valueOf(arrayId[0]);
            docNo = docNo.substring(0, 6) + docNo.substring(9);
            entity.setValue(MpmProjectReviewEntity.FieldDocno, docNo);
            MpmProjectReviewEntity mpmprojectreview = (MpmProjectReviewEntity) entity;
            // 设置是否完成自评字段
            String projectCode = mpmprojectreview.getProjectcode();
            mpmprojectreview.setHavebidscoredata(ConvertUtil.convertToString(mpmProjectBidScoreService.queryScoreTimes(projectCode)));
            // 新增第三次自评
            mpmProjectBidScoreService.insertThirdTimeScoreInfo(projectCode);
            //赋值复盘编号
            String reviewcode= MpmSystemConst.ReviewPrefix;
            StringBufferProxy sql = new StringBufferProxy();
            sql.appendSingle("projectcode='{0}'", projectCode);
            List<MpmProjectEntity> mpmProjectEntities = mpmProjectService
                .queryByWhere(sql.toString());
            String projectlevel = mpmProjectEntities.get(0).getProjectlevel();
            projectlevel= datacodeCache.getValueDynamic("MpmProjectLevel", projectlevel, "code", "name");
            SimpleDateFormat sdFormat = new SimpleDateFormat("yyMMdd");
            String datacode = sdFormat.format(new Date());
            String substring = datacode.substring(0, 4);
            String flowCode = docNo.substring(docNo.length() - 3);
            reviewcode=reviewcode+projectlevel+substring+flowCode;
            entity.setValue(MpmProjectReviewEntity.FieldReviewcode,reviewcode);
        }
    }


    @Override
    protected void beforeSubmit(TapEntity entity, SessionUserBean sessionUserBean) {
		super.beforeSubmit(entity, sessionUserBean);
    	MpmProjectReviewEntity mpmProjectReviewEntity = (MpmProjectReviewEntity) entity;
        this.flowidList= flowDatacodeCache
            .getApprovalFlowListMap("ApprovalFlow_MpmProjectReview",
                mpmProjectReviewEntity.getApplyusercode(), "sortcode");
        if(flowidList.size()>0){
        	mpmProjectReviewEntity.setFlowid(ConvertUtil.convertToLong(flowidList.get(0).get("id")));
		}else{
			throw new ServiceException("没有匹配的审批流，请联系管理员！");
		}
    }

    /**
     * @author: chengengwei
     * @date: 2021-07-30
     * @description:判断是否完成了里程碑及任务总结
     * @modify:
     */
    @Override
    public Boolean judgeFinishProcessAnalysis(Map<String, Object> paraMap) {
        String projectcode = ConvertUtil.convertToString(paraMap.get("projectcode"));
        StringBufferProxy whereSql = new StringBufferProxy();
        whereSql.appendSingle(" {0} = '{1}' and enabled = 1 and ({2} is null or {3} is null) and exists (select 1" +
                        " from MpmProjectPlan p where MpmProjectMilePost.planid = p.id and p.state = '9')",
                MpmProjectMilepostEntity.FieldProjectcode, projectcode,
                MpmProjectMilepostEntity.FieldCompletionstatus,
                MpmProjectMilepostEntity.FieldDifferenceanalysis);
        int count = this.mpmProjectMilepostService.getCount(whereSql.toString());
        return count <= 0;
    }

    /**
     * @author: chengengwei
     * @date: 2021-07-31
     * @description: 删除复盘信息的同时删除中标信息
     * @modify:
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteReviewAndWinBidInfo(Map<String, Object> paraMap) {
        paraMap = BaseUtil.decodeSecureMap(paraMap);
        String ids = ConvertUtil.convertToString(paraMap.get("ids"));
        StringBufferProxy whereSql = new StringBufferProxy();
        whereSql.appendSingle("id in ({0})", ids);
        this.deleteByWhere(whereSql.toString());
        whereSql.clear();
        // 查询关联的中标信息并删除
        whereSql.appendSingle("reviewid in ({0})", ids);
        this.mpmProjectWinBidInfoService.deleteByWhere(whereSql.toString());
    }

    /**
     * @author: chengengwei
     * @date: 2021-08-28
     * @description: 修改项目是否公开的权限
     * @modify:
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String changePermission(Map<String, Object> paraMap) {
        String projectcode = paraMap.get("projectcode").toString();
        List<MpmProjectEntity> entities = this.mpmProjectService.queryByWhere(" projectcode = '" + projectcode + "' ");
        String message = "";
        if (!entities.isEmpty()) {
            if (entities.get(0).getOpen() == 1) {
                entities.get(0).setOpen(0);
                message = "取消公开成功！";
            } else {
                entities.get(0).setOpen(1);
                message = "公开成功！";
            }
            this.mpmProjectService.updateEntity(entities.get(0));
        } else {
            throw new ServiceException("找不到该项目记录！");
        }
        return message;
    }

    /**
     * @author: chengengwei
     * @date: 2021-09-01
     * @description: 判断为正常结项还是异常结项，正常结项返回true
     * @modify:
     */
    @Override
    public Boolean judegEndTpye(Map<String, Object> paraMap) {
        StringBufferProxy whereSql = new StringBufferProxy();
        String projectcode = paraMap.get("qry_projectcode").toString();
        whereSql.appendSingle(" projectcode = '{0}' and taskstate in ({1}, {2}) and state = 9 ",
                projectcode,
                MpmSystemConst.TaskStateCode.TaskNotStartCode,
                MpmSystemConst.TaskStateCode.TaskIncompleteCode);
        // 未完成的任务数(任务已下发且任务状态为未开始、进行中)
        int unfinishedTaskCount = this.mpmProjectTaskService.getCount(whereSql.toString());
        whereSql.clear();
        // 未达成的里程碑及任务数
        whereSql.appendSingle(" projectcode = '{0}' and milepoststate = '{1}' and enabled = 1 " ,
                projectcode, MpmSystemConst.MilepostStateCode.MilepostIncompleteCode);
        int unfinishedMilePostCount = this.mpmProjectMilepostService.getCount(whereSql.toString());
        whereSql.clear();
        // 已达成的里程碑及任务数
        whereSql.appendSingle(" projectcode = '{0}' and milepoststate = '{1}' and enabled = 1 ",
                projectcode, MpmSystemConst.MilepostStateCode.MilepostCompleteCode);
        int finishedMilePostCount = this.mpmProjectMilepostService.getCount(whereSql.toString());
        return unfinishedTaskCount == 0 && unfinishedMilePostCount == 0 && finishedMilePostCount > 0;
    }

    /**
     * @author zhangjunyao
     * @Description 联表查询复盘项目相关信息（复盘归档用）
     * @Date 2021/12/14
     * @return
     **/
    @Transactional
    public void getProjectInfo(List<Map<String, Object>> tempList) {
        String projectCodes = tempList.stream().map(map -> ConvertUtil.convertToString(map.get("projectcode")))
                .collect(Collectors.joining("','", "'", "'"));
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle("projectcode in ({0})", projectCodes);
        List<MpmProjectEntity> projectEntities = mpmProjectService.queryByWhere(sql.toString());
        if (CollectionUtils.isEmpty(projectEntities)) {
            return;
        }
        Map<String, MpmProjectEntity> resultMap = projectEntities.stream().collect(Collectors.toMap(
                MpmProjectEntity::getProjectcode, mpmProjectEntity -> mpmProjectEntity, (v1, v2) -> v1));
        for (Map<String, Object> mapRow : tempList) {
            String projectCode = ConvertUtil.convertToString(mapRow.get("projectcode"));
            if (resultMap.containsKey(projectCode)) {
                MpmProjectEntity mpmProjectEntity = resultMap.get(projectCode);
                mapRow.put("deptname", mpmProjectEntity.getDeptname());
                String projectlevel = mpmProjectEntity.getProjectlevel();
                mapRow.put("dispprojectlevel", datacodeCache.getValueDynamic("MpmProjectLevel", projectlevel,
                        "code", "name"));
                mapRow.put("projectmanager", mpmProjectEntity.getProjectmanager());
            }
        }
    }

    /**
     *
     * @param projectCode
     * @author zhangjunyao
     * @date 2022-02-16
     * @description 判断是否已经提交复盘
     * @return boolean
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean ifReviewed(String projectCode) {
        boolean ifReviewed = false;
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" projectcode = '{0}' and state in (1,9) ", projectCode);
        List<MpmProjectReviewEntity> mpmProjectReviewEntity = this.queryByWhere(sql.toString());
        if (!CollectionUtils.isEmpty(mpmProjectReviewEntity)) {
            ifReviewed = true;
        }
        return ifReviewed;
    }
    /**
     * @author: houyuhang
     * @date: 2022-07-28
     * @param entity
     * @throws ServiceException
     * @description: 新增复盘后执行
     * @modify:
     */
    @Override
    protected void afterInsert(BasicEntity entity) {
        super.afterInsert(entity);
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" apply.enabled = 1 and apply.mpmprojectcode like '%{0}%' and apply.state in ('1','9') ", ConvertUtil.convertToString(entity.getValue("projectcode")));
        List<Map<String, Object>> dataList = mpmProjectService.queryMapByWhere(sql.toString(), "ltcBidWinInfo");
        if (CollectionUtil.isEmpty(dataList)) {
            return;
        }
        List<BasicEntity> insertList = new ArrayList<>();
        for(Map<String, Object> dataMap : dataList) {
            insertList.add(this.concatWinBidInfo(dataMap, entity.convertToMap()));
        }
        mpmProjectWinBidInfoService.insertBatch(insertList);
    }
    /**
     * @author: houyuhang
     * @date: 2022-07-28
     * @description: 拼接中标map
     * @modify:
     */
    public MpmProjectWinBidInfoEntity concatWinBidInfo(Map<String, Object> dataMap, Map<String, Object> entity) {
        MpmProjectWinBidInfoEntity mpmProjectWinBidInfoEntity = new MpmProjectWinBidInfoEntity();
        mpmProjectWinBidInfoEntity.setProjectname(ConvertUtil.convertToString(entity.get("projectname")));
        mpmProjectWinBidInfoEntity.setProjectcode(ConvertUtil.convertToString(entity.get("projectcode")));
        mpmProjectWinBidInfoEntity.setReviewid(ConvertUtil.convertToLong(entity.get("id")));
        mpmProjectWinBidInfoEntity.setBidpackagenumber(ConvertUtil.convertToString(dataMap.get("package_number")));
        mpmProjectWinBidInfoEntity.setBidresult(ConvertUtil.convertToString(dataMap.get("bidresult")));
        mpmProjectWinBidInfoEntity.setBulletintime(ConvertUtil.convertToDate(dataMap.get("bulletintime")));
        mpmProjectWinBidInfoEntity.setPartake(ConvertUtil.convertToString(dataMap.get("partake")));
        // 如果厂家为name，直接赋值；如果厂家为code，解析字段值
        String temp;
        if (dataMap.get("bid_win_manufactor") != null) {
            temp = dataMap.get("bid_win_manufactor").toString();
            String dispbid_win_manufactor = datacodeCache.getValueDynamic("LtcBidCompany", temp, "code", "name");
            if (dispbid_win_manufactor.isEmpty()) {
                dataMap.put("dispbid_win_manufactor", temp);
            } else {
                dataMap.put("dispbid_win_manufactor", dispbid_win_manufactor);
            }
        }
        mpmProjectWinBidInfoEntity.setBidmanufactor(ConvertUtil.convertToString(dataMap.get("dispbid_win_manufactor")));
        mpmProjectWinBidInfoEntity.setBidwinfund(ConvertUtil.convertToString(dataMap.get("bid_win_fund")));
        mpmProjectWinBidInfoEntity.setAutoflag(1);
        return mpmProjectWinBidInfoEntity;
    }
    /**
     * @author: houyuhang
     * @date: 2022-08-01
     * @throws ServiceException
     * @description: 从投标拉取中标信息
     * @modify:
     */
    @Transactional
    public boolean getBidGuideInfo(Map<String, Object> paraMap) {
        // 删除复盘关联的中标信息
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" reviewid = '{0}' and projectcode = '{1}' ", ConvertUtil.convertToString(paraMap.get("id")), ConvertUtil.convertToString(paraMap.get("projectcode")));
        mpmProjectWinBidInfoService.deleteByWhere(sql.toString());
        // 查询是否关联了投标项目
        sql.clear();
        sql.appendSingle(" apply.enabled = 1 and apply.mpmprojectcode like '%{0}%' ", ConvertUtil.convertToString(paraMap.get("projectcode")));
        List<Map<String, Object>> applyList = mpmProjectService.queryMapByWhere(sql.toString(), "ltcBidApplyInfo");
        if (CollectionUtil.isEmpty(applyList)) {
            return false;
        }
        // 关联了投标获取投标信息,如果关联了投标且没有中标信息，复盘不允许提交审批
        sql.clear();
        sql.appendSingle(" apply.enabled = 1 and apply.mpmprojectcode like '%{0}%' and apply.state in ('1','9') ", ConvertUtil.convertToString(paraMap.get("projectcode")));
        List<Map<String, Object>> dataList = mpmProjectService.queryMapByWhere(sql.toString(), "ltcBidWinInfo");
        if (CollectionUtil.isEmpty(dataList)) {
            return true;
        }
        List<BasicEntity> insertList = new ArrayList<>();
        for(Map<String, Object> dataMap : dataList) {
            insertList.add(this.concatWinBidInfo(dataMap, paraMap));
        }
        mpmProjectWinBidInfoService.insertBatch(insertList);
        return false;
    }
    /**
     * @author:houyuhang
     *      * @date: 2022-08-01
     *      * @throws ServiceException
     *      * @description: 删除复盘时同步删除中标信息
     *      * @modify:
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    protected void deleteBefore(String whereSql) {
        super.deleteBefore(whereSql);
        //找到这条复盘
        List<MpmProjectReviewEntity> mpmProjectReviewEntities = this.queryByWhere(whereSql);
        if (mpmProjectReviewEntities.size() == 0) {
            return;
        }
        // 获取复盘的id
        String reviewid = ConvertUtil.convertToString(mpmProjectReviewEntities.get(0).getId());
        // 删除对应的中标信息
        StringBufferProxy delsql = new StringBufferProxy();
        delsql.appendSingle("reviewid = '{0}' ", reviewid);
        mpmProjectWinBidInfoService.deleteByWhere(delsql.toString());
        // 删除对应的项目成员评价信息
        delsql.clear();
        String projectcode = ConvertUtil.convertToString(mpmProjectReviewEntities.get(0).getProjectcode());
        delsql.appendSingle(" projectcode = '{0}' ", projectcode);
        mpmProjectPerformanceJudgeService.deleteByWhere(delsql.toString());
    }
    /**
     * @author: houyuhang
     * @date: 2022-10-26
     * @throws ServiceException
     * @description: 主表更新之后，更新绩效评价子表信息
     * @modify:
     */
    @Override
    protected void updateAfter(Map<String, Object> map) throws ServiceException {
        List<Map<String, Object>> performanceList = (List<Map<String, Object>>) map.get("performancelist");
        if (CollectionUtil.isEmpty(performanceList)) {
            return;
        }
        mpmProjectPerformanceJudgeService.updateBatchMap(performanceList);
    }
    /**
     * @param paraMap
     * @author houyuhang
     * @date 2022-12-15
     * @description 保存项目类型(销售类、推广类)信息
     */
    @Transactional(rollbackFor = Exception.class)
    public void savePmoProjectType(Map<String, Object> paraMap) {
        String pmoProjectType = ConvertUtil.convertToString(paraMap.get("pmoprojecttype"));
        String projectcode = ConvertUtil.convertToString(paraMap.get("projectcode"));
        // 修改主表项目类型信息
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" enabled = 1 and projectcode = '{0}' ", projectcode);
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("pmoprojecttype", pmoProjectType);
        mpmProjectService.updateByWhere(dataMap, sql.toString());
        // 修改历史表项目类型信息
        sql.clear();
        sql.appendSingle(" enabled = 1 and projectcode2 = '{0}' and state < 9 ", projectcode);
        dataMap.clear();
        dataMap.put("pmoprojecttype2", pmoProjectType);
        mpmProjectChangeService.updateByWhere(dataMap, sql.toString());
        // 修改复盘项目结果
        if (!ObjectUtil.isEmpty(paraMap.get("result"))) {
            String projectresult = ConvertUtil.convertToString(paraMap.get("result"));
            sql.clear();
            sql.appendSingle(" enabled = 1 and projectcode = '{0}' ", projectcode);
            dataMap.clear();
            dataMap.put("projectresult", projectresult);
            if (!ObjectUtil.isEmpty(paraMap.get("resulttime"))) {
                dataMap.put("resulttime", ConvertUtil.convertToDate(paraMap.get("resulttime")));
            }
            this.updateByWhere(dataMap, sql.toString());
        }
    }
    /**
     * @param paraMap
     * @author houyuhang
     * @date 2023-04-13
     * @description 获取历史复盘信息
     */
    public Page getReviewForBidScore(Map<String, Object> paraMap) {
        // 获取项目信息
        Query query = new Query(paraMap);
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" projectcode = '{0}' ", ConvertUtil.convertToString(paraMap.get("qry_projectcode")));
        List<MpmProjectEntity> mpmProjectEntities = mpmProjectService.queryByWhere(sql.toString());
        if (CollectionUtil.isEmpty(mpmProjectEntities)) {
            throw new ServiceException("未查询到项目，请联系管理员！");
        }
        // 拼接筛选条件sql
        String whereSql = this.spellSqlForBidScore(paraMap);
        if (!StringUtil.isEmpty(whereSql)) {
            paraMap.put("whereSql", whereSql);
        }
        // 获取已结项且符合要求的所有项目，识别产品名称与当前项目一致的项目
        MpmProjectEntity mpmProjectEntity = mpmProjectEntities.get(0);
        paraMap.put("deptcommoncode", mpmProjectEntity.getDeptcommoncode());
        paraMap.put("projectmanager", mpmProjectEntity.getProjectmanagercode());
        List<Map> entityRangeList = JSONObject.parseArray(mpmProjectEntity.getProductrange(), Map.class);
        List<String> projectcodeList = new ArrayList<>();
        if (!CollectionUtil.isEmpty(entityRangeList)) {
            String entityRangeStr = entityRangeList.stream().map(item -> ConvertUtil.convertToString(item.get("productType"))).collect(Collectors.joining(",", ",",","));
            List<Map<String, Object>> rangeList = this.queryMap(paraMap, "queryReviewByWhere");
            for (Map<String, Object> rangeMap : rangeList) {
                List<Map> tempProductList = JSONObject.parseArray(ConvertUtil.convertToString(rangeMap.get("productrange")), Map.class);
                if (CollectionUtil.isEmpty(tempProductList)) {
                    continue;
                }
                if (tempProductList.stream().anyMatch(item -> entityRangeStr.contains(ConvertUtil.convertToString(item.get("productType"))))) {
                    projectcodeList.add(ConvertUtil.convertToString(rangeMap.get("projectcode")));
                }
            }
            paraMap.put("projectcodes", String.join("','", projectcodeList));
        }
        // 分页获取符合条件的项目，按照产品与当前项目产品有重合、项目经理为本人、结果公布时间倒序、项目级别正序排序
        int totalCount = this.getCount(paraMap, "queryReviewForCount");
        List<Map<String, Object>> tempList = this.queryMapForPage(query.getCurrentPage(), query.getPageSize(), query.getSidx(), query.getSord(), paraMap, "queryReviewForPage");
        this.setDispFields(tempList);
        return new Page(tempList, totalCount, query.getPageSize(), query.getCurrentPage());
    }
    /**
     * @author: houyuhang
     * @date: 2023-04-14
     * @param paraMap
     * @return
     * @description:转换出查询SQL语句
     * @modify:
     */
    protected String spellSqlForBidScore(Map<String, Object> paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" mpmproject.enabled=1 ");
        if (paraMap.containsKey("qry_projectname")) {
            String value = paraMap.get("qry_projectname").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and (mpmproject.projectname like '%{0}%' or mpmproject.projectcode like '%{0}%')", value);
        }
        if (paraMap.containsKey("qry_projectmanager")) {
            String value = paraMap.get("qry_projectmanager").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and mpmproject.projectmanager like '%{0}%' ", value);
        }
        return sql.toString();
    }
}
